import { Component } from "@angular/core";
import {NavController,NavParams} from 'ionic-angular';
import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal';
@Component({
    selector: 'page-pay',
    templateUrl: 'renewlist.html',
})

export class RenewlistPage{
    type = 1;
    date ="";
    constructor(
        private navCtl: NavController,
        private payPal: PayPal,
        private navParams: NavParams
    ) {
        console.log(this.navParams.get('data'));
    }
    pay(){
        this.payPal.init({
            PayPalEnvironmentProduction: '',
            PayPalEnvironmentSandbox: 'AUQPJbVFoszLBf5Fe7GY81IN2NA3Af5lk9FVIZZjGGkIAgzJq10qfezS'
          }).then(() => {
            // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
            this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
              // Only needed if you get an "Internal Service Error" after PayPal login!
              //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
            })).then(() => {
                let payment = new PayPalPayment('3.33', 'USD', '', 'sale');
                this.payPal.renderSinglePaymentUI(payment).then((res) => {
                    console.log(res)
                    // Successfully paid
            
                    // Example sandbox response
                    //
                    // {
                    //   "client": {
                    //     "environment": "sandbox",
                    //     "product_name": "PayPal iOS SDK",
                    //     "paypal_sdk_version": "2.16.0",
                    //     "platform": "iOS"
                    //   },
                    //   "response_type": "payment",
                    //   "response": {
                    //     "id": "PAY-1AB23456CD789012EF34GHIJ",
                    //     "state": "approved",
                    //     "create_time": "2016-10-03T13:33:33Z",
                    //     "intent": "sale"
                    //   }
                    // }
                }, () => {
                });
            }, () => {
            });
          }, () => {
            
        });
    }
}